package parder

import (
	"fmt"
	"log"
	"math/rand"
	"parser/engine"
	"time"
)

var Global = make(chan string)

type IpAndProxy struct {
	Mi    string
	Proxy string
}
type IpScore struct {
	Ip    string
	Score bool
}

func init() {
	mis := []string{"com", "cn", "xin", "net", "top", "xyz", "cc", "fun", "biz", "red", "ltd", "org", "vip", "pro", "tv", "co", "kim", "ren", "ink", "pub", "art"}
	go func() {
		rand.Seed(time.Now().UnixNano())
		for i := 'a'; i <= 'z'; i++ {
			for j := 'a'; j <= 'z'; j++ {
				for k := 'a'; k <= 'z'; k++ {
					for _, m := range mis {
						mi := string(i) + string(j) + string(k) + "." + m
						Global <- mi
					}
				}
			}
		}
		close(Global)
	}()
}

func Mi(content []byte) engine.ParserResult {


	fmt.Println(string(content))


	result := engine.ParserResult{}
	basaUrl:= "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain="
	basaUrl = "http://192.168.43.67?mi="
	//log.Fatal("okjojojojo")
	for i:=1;i<=10;i++ {
		if do ,ok := <-Global; ok{
			req:= engine.Request{Url:basaUrl+do , ParserFunc: Mi,  Query:do }
			result.Requests  = append(result.Requests,req)
			//result.Items  = append(result.Items,do.Proxy+ "-------")
		}
	}
	return result
}

func MiErr (content []byte) engine.ParserResult{
	fmt.Println(string(content))
	log.Fatal()
	return engine.ParserResult{}
}
